package me.jessyan.armscomponent.app.mvp.model.user;

import android.app.Application;

import com.google.gson.Gson;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import java.util.HashMap;
import java.util.Map;

import javax.inject.Inject;

import io.reactivex.Observable;
import me.jessyan.armscomponent.app.mvp.contract.user.UserRetrievePasswordContract;
import me.jessyan.armscomponent.app.mvp.model.api.service.UserService;
import me.jessyan.armscomponent.app.mvp.model.entity.RetrievePasswordRequest;
import me.jessyan.armscomponent.commonsdk.http.BaseResponse;


/**
 * <p>
 * Author: Taozebi
 * Date: 08/08/2021 15:36
 * Description: describe of this class
 */
@ActivityScope
public class UserRetrievePasswordModel extends BaseModel implements UserRetrievePasswordContract.Model {
    @Inject
    Gson mGson;
    @Inject
    Application mApplication;

    @Inject
    public UserRetrievePasswordModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }

    @Override
    public Observable<BaseResponse<Object>> forgetLoginPwd(RetrievePasswordRequest loginRequest) {
        return mRepositoryManager.obtainRetrofitService(UserService.class).forgetLoginPwd(loginRequest);
    }

    @Override
    public Observable<BaseResponse<Object>> checkMobile(String mobile) {
        Map<String,String> dataMap = new HashMap<>();
        dataMap.put("mobile",mobile);
        return mRepositoryManager.obtainRetrofitService(UserService.class).checkMobile(dataMap);
    }

    @Override
    public Observable<BaseResponse<Object>> smsCaptcha(String mobile) {
        Map<String,String> dataMap = new HashMap<>();
        dataMap.put("mobile",mobile);
        return mRepositoryManager.obtainRetrofitService(UserService.class).smsCaptcha(dataMap);
    }
}